﻿@model RSHB.Frontend.UI.ViewModels.HomeBrowseViewModel

@{
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h3>Кредитные договора</h3>
<table class="list" cellspacing="0" cellpadding="0" border="0">
<thead>
    <tr>
        <td>Номер</td>
        <td>Заемщик</td>
        <td>Сумма</td>
        <td>Процентная ставка</td>
        <td>Дата заключения</td>
        <td>Дата возврата</td>
    </tr>
</thead>
<tfoot>
    <tr>
        <td colspan="5">Всего: @Model.LoanAgreementsViewModel.LoanAgreements.Count</td>
    </tr>
</tfoot>
<tbody>
@foreach (var loanAgreement in Model.LoanAgreementsViewModel.LoanAgreements)
{
    <tr>
        <td>@Html.ActionLink(@loanAgreement.LoanAgreementNum, "Edit", "LoanAgreement", new { id = loanAgreement.LoanAgreementID }, null)</td>
        <td>
            @Html.ActionLink(
                @loanAgreement.Borrower.FIO, "Edit", "Individual",  new { id = loanAgreement.User.UserID }, null)
        </td>
        <td>@loanAgreement.LoanAgreementAmount.ToString("0.00")</td>
        <td>@loanAgreement.LoanAgreementRate.ToString("0.00")% (@loanAgreement.LoanAgreementFullRate.ToString("0.00")%)</td>
        <td>@loanAgreement.LoanAgreementIssueDate.ToString("dd.MM.yyyy")</td>
        <td>@loanAgreement.LoanAgreementRepaymentDate.ToString("dd.MM.yyyy")</td>
    </tr>
}
</tbody>
</table>


<h3>Физические лица</h3>
<table class="list"cellspacing="0" cellpadding="0" border="0">
<thead>
    <tr>
        <td>ФИО</td>
        <td>Роли</td>
    </tr>
</thead>
<tfoot>
    <tr>
        <td colspan="5">Всего: @Model.UsersViewModel.Individuals.Count</td>
    </tr>
</tfoot>
<tbody>
@foreach (var user in Model.UsersViewModel.Individuals)
{
    <tr>
        <td>@Html.ActionLink(string.Format("{0} {1} {2}", @user.VCards.SingleOrDefault().vcardNameLast, @user.VCards.SingleOrDefault().vcardNameFirst, @user.VCards.SingleOrDefault().vcardNameMiddle), "Edit", "Individual", new { id = user.UserID }, null)</td>
        <td>
            Заемщик: 
            @foreach (var asBorrower in user.LoanAgreements)
            {
                <span>@Html.ActionLink(string.Format("{0} ({1})", asBorrower.LoanAgreementTitle, asBorrower.LoanAgreementNum), "Edit", "LoanAgreement", new { id = asBorrower.LoanAgreementID }, null)</span>
            }
            <br />
            Созаемщик: 
            @foreach (var asCoBorrower in user.LoanAgreements1)
            {
                <span>@Html.ActionLink(string.Format("{0} ({1})", asCoBorrower.LoanAgreementTitle, asCoBorrower.LoanAgreementNum), "Edit", "LoanAgreement", new { id = asCoBorrower.LoanAgreementID }, null)</span>
            }
        </td>
    </tr>
}
</tbody>
</table>


